home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 January / PCWorld_2007-01_cd.bin / v cisle / hotkey / AutoHotkey104504_Install.exe / Extras / Run this to install syntax and clip files for jEdit.ahk < prev    next >
Text File  |  2006-08-29  |  5KB  |  148 lines

  1. ;;; ============================================================================
  2. ;;;   FILENAME: Run this to install syntax and clip files for ahk.xml
  3. ;;; ============================================================================
  4. ;;;   Install AutoHotkey syntax highlighting and clip files in jEdit
  5. ;;; ============================================================================
  6.  
  7. ;;;   AUTHOR:  Andreas Gleichmann
  8. ;;;   VERSION: 1.0.0, 26.05.2005
  9. ;;;       Based on installscript 'Run this to install syntax and clip files for PSPad.ahk' from Scott Greenberg
  10. ;;;
  11. ;;; ============================================================================
  12. ;;;   HISTORY:
  13. ;;; ============================================================================
  14. ;;;   DISCLAIMER:
  15. ;;;   Permission to use, copy, modify, and distribute this software 
  16. ;;;   for any purpose and without fee is hereby granted, provided 
  17. ;;;   that the above copyright notice appears in all copies and that 
  18. ;;;   both that copyright notice and this permission notice appear in 
  19. ;;;   all supporting documentation.
  20. ;;;
  21. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
  22. ;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
  23. ;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
  24. ;;; ============================================================================
  25.  
  26. ;;; Directives, required by this script (do not change)
  27. #SingleInstance force
  28. #EscapeChar \
  29. SetBatchLines,-1
  30. ScriptTitle = AutoHotkey jEdit Setup
  31. ;;;  Used to aid in bugging script
  32. ;; debugging on  = 1
  33. ;; debugging off = 0
  34. bDebug = 0
  35. IfNotEqual, bDebug, 1
  36. {
  37.     MsgBox, 4, %ScriptTitle%, This will install file for jEdit to handle AutoHotkey scripts.\nWould you like to continue with the install?
  38.     IfMsgBox, No
  39.         ExitApp
  40. }
  41.  
  42.  
  43. jEditTitleName=jEdit - 
  44. jEditUserPath=%USERPROFILE%\\.jedit
  45. jEditCatalogPath=%jEditUserPath%\\modes
  46. jEditCatalogFile=catalog
  47. jEditSyntaxFile=ahk.xml
  48. jEditCatalogPathFile=%jEditCatalogPath%\\%jEditCatalogFile%
  49. ;;; Allow user to select from dialog, when unable to locate PSPad
  50. IfNotExist, %jEditCatalogPath%
  51.     FileSelectFile, jEditCatalogPathFile, 1, %jEditCatalogPath%\\%jEditCatalogFile%, Select the jEdit catalog File.
  52. SplitPath, jEditCatalogPathFile, jEditCatalogFile, jEditCatalogPath
  53. IfEqual, bDebug, 1
  54.     MsgBox, 0, %ScriptTitle%, jEditCatalogPathFile:%jEditCatalogPathFile%, jEditCatalogFile:%jEditCatalogFile%, jEditCatalogPath:%jEditCatalogPath%
  55.  
  56. ;;; Discover where AutoHotkey and its related files reside.
  57. RegRead, AhkDir, HKLM, SOFTWARE\\AutoHotkey, InstallDir
  58. if (ErrorLevel or not FileExist(AhkDir . "\\AutoHotkey.exe"))  ; Not found, so try best-guess instead.
  59.     SplitPath, A_AhkPath,, AhkDir
  60. AHKExe = %AhkDir%\\AutoHotkey.exe
  61.  
  62. ;;; Allow user to select from dialog, when unable to locate AutoHotkey
  63. IfNotExist, %AHKExe%
  64.     FileSelectFile, AHKExe, 1, %A_ProgramFiles%\\AutoHotkey\\AutoHotkey.exe, Select the AutoHotkey executable., Executable (*.exe)
  65. IfNotExist, %AHKExe%
  66.     Goto, DownloadAHK
  67.  
  68. ;;; Copy files to jEdit dir
  69. file = %A_WORKINGDIR%\\%jEditSyntaxFile%
  70. IfExist, %file%
  71. {
  72.     ; Make backup of old file if it exists and if there isn't already a backup file (this relies
  73.     ; on it failing to do anything otherwise):
  74.     FileMove, %jEditCatalogPath%\\%jEditSyntaxFile%, %jEditCatalogPath%\\%jEditSyntaxFile%.backup
  75.     FileCopy, %file%, %jEditCatalogPath%, 1
  76. }
  77.  
  78. ;;; add the syntax file to the jEdit catalog
  79. ;;search <MODE NAME="ahk" FILE="ahk.xml" FILE_NAME_GLOB="*.{ahk}"/> in catalog file
  80. Found=0
  81. IfEqual, bDebug, 1
  82.     MsgBox, 0, %ScriptTitle%, Search %jEditCatalogPathFile%.
  83. Loop, Read, %jEditCatalogPathFile%
  84. {
  85.     ifInString, A_LoopReadLine, NAME="ahk"
  86.     {
  87.     IfEqual, bDebug, 1
  88.         MsgBox, 0, %ScriptTitle%, AHK Syntaxfile already exist in the catalog file. Nothing to do
  89.     Found=1
  90.     break
  91.     }
  92. }
  93.  
  94. if Found=0
  95. {
  96.     ;;; Close jEdit
  97.     IfWinExist, %jEditTitleName%
  98.     {
  99.     If bDebug <> 1
  100.         WinClose ; use the window found above
  101.     }
  102.     
  103.    jEditCatalogPathFile_new=%jEditCatalogPathFile%_new
  104.     IfEqual, bDebug, 1
  105.         MsgBox, 0, %ScriptTitle%, Add AHK Syntaxfile to the catalog file %jEditCatalogPathFile_new%.
  106.  
  107.     IfExist, %jEditCatalogPathFile_new%, FileDelete, %jEditCatalogPathFile_new%
  108.     
  109.     Loop, Read, %jEditCatalogPathFile%, %jEditCatalogPathFile_new% 
  110.     {
  111.     ifInString, A_LoopReadLine, </MODES>
  112.     {
  113.         IfEqual, bDebug, 1
  114.             MsgBox, 0, %ScriptTitle%, Add definition line to the catalog file.
  115.         FileAppend, <MODE NAME="ahk" FILE="ahk.xml" FILE_NAME_GLOB="*.{ahk}"/>\n
  116.     }
  117.     FileAppend, %A_LoopReadLine%\n
  118.     }
  119.     IfExist, %jEditCatalogPathFile%.backup, FileDelete, %jEditCatalogPathFile%.backup
  120.     FileMove, %jEditCatalogPathFile%, %jEditCatalogPathFile%.backup
  121.     FileMove, %jEditCatalogPathFile_new%, %jEditCatalogPathFile%
  122. }
  123.  
  124. ExitApp
  125.  
  126.  
  127. DownloadAHK:
  128. url = http://www.autohotkey.com/
  129. valSet := 0
  130. Gui, Font, norm
  131. Gui, Add, Text,, We sure AutoHotkey is installed but we are unable to find it. Unable to continue.
  132. Gui, Font, underline
  133. Gui, Add, Text, cBlue gOpenLink, Click here to Download AutoHotkey.
  134. Gui, Font, norm
  135. Gui, Add, Button, Default, &OK
  136. Gui, Show, AutoSize, ScriptTitle
  137. Loop
  138. {
  139.     if valSet
  140.         break
  141. }
  142. ExitApp -1
  143.  
  144. OpenLink: 
  145. Run, %url%
  146. ExitApp -1
  147. return
  148.